package com.hspedu.innerclass;

/**
 * 演示匿名内部类的使用（接口）
 */
public class LocalInnerClass {//

    public static void main(String[] args) {
        Demo demo = new Demo() {
            MyInter myInter = new MyInter() {
                @Override
                public void cry() {
                    System.out.println("嘿嘿 没想到吧！");
                }
            };
        };
        Demo demo1 = new Demo();
        demo.demo();
        demo1.demo1();
    }
}

interface MyInter {
    void cry();
}

class Demo {
    private String name = "DemoName";

    public void demo() {
        String name = "江雪滢";
        MyInter myInter = new MyInter() {
            @Override
            public void cry() {
                System.out.println("我的名字：" + name);
            }
        };
    }

    public void demo1() {
        MyInter myInter = new MyInter() {
            @Override
            public void cry() {
                System.out.println("我的名字：" + Demo.this.name);
            }
        };
    }
}